<?php 
require_once('header_redirection.php');
require_once('Class/connexionDB.Class.php');
require_once('Class/account.Class.php');
require_once('Class/evaluation.Class.php');
require_once('Class/session.Class.php');
	
$session = session::getInstance();
$form = new evaluation();
$errors = $form->isValidForm($_POST);

if ($errors == NULL)
{
	if (isset($_POST['visualisation']) && $_POST['visualisation'] == 'visual') //Visualiser :
	{
		$session->getDataRating = $form->cleanArray($_POST);
		header('Location: create_new_rating.php');
	}
	else // Ajout du nouveau formulaire :
	{
		if (isset($_POST['evaluationName']))
		{
			$form->addNewEvaluationType($_POST);
			header('Location: create_new_rating.php?evaluation=' . $_POST['evaluationName']);	
		}
		
	}
}
else
{
	$errorsGETURL = '?';
	foreach ($errors as $key => $value)
	{
		if (isset($errors[$key]))
		{
			$errorsGETURL .= $key . '=' . $value . '&';
		}
	}
	header('Location: create_new_rating.php' . $errorsGETURL);
}

?>